//
//  XBOAuth.m
//  XBShare
//
//  Created by admin on 2018/5/14.
//  Copyright © 2018年 肖世恒. All rights reserved.
//

#import "XBOAuth.h"
#import "QQApiInterface.h"
#import "TencentOAuth.h"
#import "WXApi.h"
#import "WeiboSDK.h"

@interface XBOAuth ()

@property (retain, nonatomic) TencentOAuth *tencentOAuth;

@end

@implementation XBOAuth


+ (XBOAuth *)defaultManager{
    
    static XBOAuth * s_instance_dj_singleton = nil ;
    if (s_instance_dj_singleton == nil) {
        s_instance_dj_singleton = [[XBOAuth alloc] init];
    }
    return s_instance_dj_singleton;
}

- (BOOL)isInstall:(XBSocialPlatformType)platformType;{
    
    if(platformType ==XBSocialPlatformType_WechatTimeLine  ||
       platformType ==XBSocialPlatformType_WechatFavorite  ||
       platformType == XBSocialPlatformType_WechatSession  ){

        BOOL isInstallWX = [WXApi isWXAppInstalled];
        return isInstallWX;
        
    }else if(platformType==XBSocialPlatformType_QQ    ||
             platformType==XBSocialPlatformType_Qzone ||
             platformType==XBSocialPlatformTypeQQAndTIM){

        BOOL isInstallQQ = [QQApiInterface isQQInstalled];
        return isInstallQQ;
        
    }else if(platformType==XBSocialPlatformType_Tim    ||
             platformType==XBSocialPlatformType_TimQZ  ||
             platformType==XBSocialPlatformTypeQQAndTIM ){

        BOOL isInstallTIM = [QQApiInterface isTIMInstalled];
        return isInstallTIM;
        
    }else if(platformType==XBSocialPlatformType_Sina){
        
        BOOL isInstallWeibo = [WeiboSDK isWeiboAppInstalled];
        return isInstallWeibo;

    }else{
        
        return YES;
    }
    
}
- (void)setWXAppId:(NSString *)appId{
    
    [WXApi registerApp:appId];
    
}
- (void)setQQAppId:(NSString *)appId{
    
    self.tencentOAuth = [[TencentOAuth alloc] initWithAppId:appId andDelegate:nil];
    
}
- (void)setWeiboAppKey:(NSString *)appKey{

    [WeiboSDK registerApp:appKey];
    
}




@end
